define([
    "app"
], function (app) {
    app.service("selectSeatDataService", [
        "$http"
        , function ($http) {
            return {
                // 这里将实际的属性放在data里边,防止由于引用发生改变,使得controller里的绑定无效
                currentTeam: {data: {}},
                hoveredSeat: {data: {}},
                seatSelected: {data: []},
                currentRoomNo: {data: "加载中"},

                // 重新初始化数据
                // 刷新链接的时候使用
                reInitData: function () {
                    this.currentRoomNo.data = "加载中";
                    this.currentTeam.data = {};
                    this.seatSelected.data = {};
                    this.seatSelected.data = [];
                },
                getAllTeamWithoutSeat: function () {
                    return $http({
                        method: "GET",
                        url: requestRootUrl + "api/select-seat/all-team-without-seat"
                    });
                },
                getAllSeatsInfo: function (roomNo) {
                    return $http({
                        method: "GET",
                        url: requestRootUrl + "api/select-seat/all-seats-info",
                        params: {
                            roomNo: roomNo
                        }
                    });
                },

                submit: function (data) {
                    return $http({
                        method: "POST",
                        url: requestRootUrl + "api/select-seat/submit",
                        data: data
                    });
                }

            }
        }])
});